package com.libing.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.libing.base.BaseDao;
import com.libing.base.BaseService;
import com.libing.dao.CompanyDao;
import com.libing.entity.Company;
import com.libing.entity.CompanyVO;
import com.libing.enums.StateEnum;
import com.libing.service.CompanyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 公司信息 CRUD Service
 * @Auther: LEE
 * @Date: Create in 2018/6/27 1:16
 */
@Service
public class CompanyServiceImpl extends BaseService<Company> implements CompanyService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private CompanyDao companyDao;

    @Override
    public StateEnum insert(Company company) {
        return getCUDStatus(getBaseDao().insert(company));
    }

    @Override
    public StateEnum update(Company company) {
        return getCUDStatus(getBaseDao().update(company));
    }

    @Override
    public StateEnum delete(Long id) {
        return getCUDStatus(getBaseDao().delete(id));
    }

    @Override
    public Company selectById(Long id) {
        try {
            return getBaseDao().selectById(id);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    @Override
    public List<CompanyVO> selectAllVO() {
        return companyDao.selectAllVO();
    }

    @Override
    protected BaseDao<Company> getBaseDao() {
        return this.companyDao;
    }

}
